package edu.gatech.stolen.tea;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

public class EditItemActivity extends Activity {
	
	private TextView userTextView;
	private EditText selectionText;
	private EditText editBox;
	private Button editButton;
	
	public static final String TAG = "Edit Item Page";
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	Log.v(TAG, "Activity State: onCreate()");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edititem);
        
        userTextView = (TextView) findViewById(R.id.tUserTextView_edititem);
        selectionText = (EditText) findViewById(R.id.eSelectionEditText_edititem);
        editBox = (EditText) findViewById(R.id.eEditItemEditText_edititem);
        editButton = (Button) findViewById(R.id.bEditButton_edititem);
        
        userTextView.setText(ItemManager.getCurrentItem().getName());
        
        editButton.setOnClickListener(new View.OnClickListener() {
        	 
      	  @Override
      	  public void onClick(View v) {
      		  
      		editItem();
      		  
      	  }
       
      	});
    	
    }
    
   public void editItem() {
    	
    	String choice = selectionText.getText().toString();
    	String change = editBox.getText().toString();
    	
    	//ItemManager.editItem(choice, change);
    	goToItemDisplayListPage();
    	
    }
    
    protected void goToItemDisplayListPage() {
    	
    	ItemManager.currentItemReset();
    	Intent i = new Intent(this, ItemDisplayListActivity.class);
    	startActivity(i);
   	
    } 
}